package com.hinner.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hinner.entity.Company;
import com.hinner.entity.vo.QueryCompanyVO;
import com.hinner.mapper.CompanyMapper;
import com.hinner.service.CompanyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {
    private static final Logger log = LoggerFactory.getLogger(CompanyServiceImpl.class);


    @Override
    public PageInfo<Company> findAllCompanies(QueryCompanyVO queryParams) {
        PageHelper.startPage(queryParams.getPageNum(),queryParams.getPageSize());
        List<Company> list = this.list(new LambdaQueryWrapper<Company>()
                .like(StringUtils.isNotEmpty(queryParams.getKeyword()),Company::getCompanyName, queryParams.getKeyword()));
        return new PageInfo<>(list);
    }
}
